import { ref } from 'vue';
import { defineStore } from 'pinia';

const isDark = JSON.parse(localStorage.getItem('isDarkTheme')) === true;
const currentLang = localStorage.getItem('language') || '';


export const useStore = defineStore('main', {
  state: () => ({
    isDark,
    currentLang
  }),
  
  getters: {
    currentTheme: (state) => state.isDark ? 'dark' : 'light',
  },
  
  actions: {
    /*toggleTheme() {
      this.isDark = !this.isDark
    },*/
    changeLang(lan) {
      this.currentLang = lan
    }
  }
  
})

export const fontSizeStore = defineStore('fontSize', () => {
  const baseSize = ref(16);
  function setBaseSize(fontSzie) {
    baseSize.value = fontSzie;
  }
  return { baseSize, setBaseSize };
});

